<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/1/23
 * Time: 12:26
 */

namespace App\Http\Controllers\Admin;


use App\Http\Logics\Admin\CityLogic;
use App\Http\Traits\CityTrait;
use App\Http\Controllers\BaseController;
class CityController extends BaseController
{
    use CityTrait;

    /**
     * 获取城市列表
     * @return string
     */
    public function getCityList()
    {
        $limit = $this->limit;
        $status = $this->status;
        $name = $this->name;
        $data = [
            'limit' => $limit,
            'status' => $status,
            'name' => $name
        ];
        $response = CityLogic::getCityList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * 设置城市状态
     * @return string
     */
    public function setCityStatus()
    {
        $city_id = $this->city_id;
        $data = [
            'city_id' => $city_id
        ];
        $response = CityLogic::setCityStatus($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * 上传城市封面
     * @return string
     */
    public function uploadBanner()
    {
        $banner_file = $this->banner_file;
        $data = [
            'banner_file' => $banner_file
        ];
        $response = CityLogic::uploadBanner($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * 设置城市基本信息
     * @return string
     */
    public function setCityBaseInfo()
    {
        $citycode = $this->citycode;
        $banner = $this->banner;
        $slogan = $this->slogan;
        $data = [
            'citycode' => $citycode,
            'banner' => $banner,
            'slogan' => $slogan
        ];
        $response = CityLogic::setCityBaseInfo($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    public function getCityBaseInfo()
    {
        $citycode = $this->citycode;
        $data = [
            'citycode' => $citycode
        ];
        $response = CityLogic::getCityBaseInfo($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}